<?php
$this->breadcrumbs=array(
    'Quản trị'=>array('/admin'),
    'Video'=>array('index'),
    'Danh sách',
);

$this->menu=array(
    array('label'=>'Thêm mới video', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('video-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Quản lý Video</h1>

<?php echo CHtml::link('Tìm kiếm','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
    <?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php
/*function renderTitle($data){
     return CHtml:link($data->title,Yii::app()->createUrl("video/view",array("vid"=>$data->id,"title"=>Yii::app()->func->safeTitle($data->title))));
}*/
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'video-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        array(
            'name'=>'title',
            'value'=>'CHtml::link($data->title,Yii::app()->createUrl("video/view",array("vid"=>$data->id,"titel"=>Yii::app()->func->safeTitle($data->title))))',
            'type'=>'html',
        ),
        array(
            'name'=>'youtube',
            'value'=>'CHtml::link($data->youtube,$data->youtube)',
            'type'=>'html',
        ),
        //'file_id',
        //'body',
        ///'update_time',
        array(
            'name'=>'create_time',
            'value'=>'date("d/m/Y",$data->create_time)',
        ),
        array(
            'name'=>'status',
            'value'=>'$data->is_trade == 1 ? "Active" : "Not Acitve"',
        ),
        array(
            'name'=>'is_trade',
            'value'=>'$data->is_trade == 1 ? "Yes" : "No"',
        ),
        array(
            'name'=>'user_id',
            'value'=>'$data->user->username',
        ),
        array(
            'name'=>'cat_id',
            'value'=>'$data->cat->name'
        ),
        'view',

        array(
            'class'=>'CButtonColumn',
            'template'=>'{delete}{update}'
        ),
    ),
)); ?>
